package com.pangus.toolkits.files.utils;

import com.pangus.toolkits.files.FSCredentials;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;

/**
 * @author yingheng chen
 * @description
 * @date 2019/11/30
 */
public class AuthUtil {
    private final static String SIGNING_KEY = "pangus";
    public final static String JWT_TOKEN = "Bearer ";
    public static String encode(FSCredentials credentials) {
        if (credentials == null || credentials.isEmpty()) {
            return "";
        }
        return Jwts.builder()
                .setSubject(credentials.getAccessKey() + "\n" + credentials.getSecretKey())
                .signWith(SignatureAlgorithm.HS512, SIGNING_KEY)
                .compact();
    }


}
